package com.example.sixtrainingdemo.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SwitchCompat;

import com.example.sixtrainingdemo.R;
import com.example.sixtrainingdemo.utils.SpUtils;

public class SettingsActivity extends AppCompatActivity implements View.OnClickListener {


   private Button mBtnLogout;
   private SpUtils mSpUtils;
   private RelativeLayout mRlAddStudent;
   private RelativeLayout mRlAddCourse;
   private RelativeLayout mRlChPassword;
   @Override
   protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_settings);

      mRlAddStudent = findViewById(R.id.look_user_view);
      mRlAddStudent.setOnClickListener(this);

      mBtnLogout = findViewById(R.id.logout_button);
      mBtnLogout.setOnClickListener(this);
      mSpUtils = new SpUtils(this);
   }

   @Override
   public void onClick(View v) {
      int id = v.getId();
      if (id == R.id.logout_button) { //退出登录
         mSpUtils.putInt(SpUtils.LOGIN_KEY, -1);
         Intent intent = new Intent(SettingsActivity.this, LoginActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(intent);
      } else if (id == R.id.look_user_view) { //跳转查看用户界面
         Intent intent = new Intent(SettingsActivity.this, UserListActivity.class);
         startActivity(intent);
//      }else if (id == R.id.add_course_view) { //跳转添加课程界面
//         Intent intent = new Intent(SettingsActivity.this, AddCourseActivity.class);
//         startActivity(intent);
//      }else if (id == R.id.add_change_password) { //跳转修改密码界面
//         Intent intent = new Intent(SettingsActivity.this, ChangePasswordActivity.class);
//         startActivity(intent);
//      }
      }


   }
}
